<%- content_for :action_bar do %>
  <ol>
    <li class="action_bar-item">
      <%= link_to t("shared.actions.back"), admin_users_path, class: "btn text-primary" %>
    </li>
    <li class="action_bar-item">
      <%= link_to t("shared.actions.edit"), edit_admin_user_path(@user), class: "btn text-primary" %>
    </li>
    <% if !@user.confirmed? || @user.pending_reconfirmation? %>
      <li class="action_bar-item">
        <%= link_to t(".actions.resend_confirmation_mail"), resend_confirmation_mail_admin_user_path(@user), method: :patch, class: "btn text-primary" %>
      </li>
    <% end %>
    <% if @user.created_by_invite? && !@user.invited_to_sign_up? %>
      <li class="action_bar-item">
        <%= link_to t(".actions.resend_invitation_mail"), resend_invitation_mail_admin_user_path(@user), method: :patch, class: "btn text-primary" %>
      </li>
    <% end %>
    <% unless @user == current_user %>
      <li class="action_bar-item">
        <% if @user.access_locked? %>
          <%= link_to t(".actions.unlock"), unlock_admin_user_path(@user), method: :patch, class: "btn text-danger", data: { confirm: t("admin.users.shared.confirmation.unlock") } %>
        <% else %>
          <%= link_to t(".actions.lock"), lock_admin_user_path(@user), method: :patch, class: "btn text-danger", data: { confirm: t("admin.users.shared.confirmation.lock") } %>
        <% end %>
      </li>
    <% end %>
  </ol>
<% end %>

<div class="row justify-content-center">
  <div class="col-lg-12">
    <div class="container">
      <h3 class="page-title">
        <%= @user.class.model_name.human %> #<%= @user.id %>
      </h3>

      <dl class="row">
        <dt class="col-sm-3">
          <%= t(".email") %>
        </dt>
        <dd class="col-sm-9">
          <%= @user.unconfirmed_email || @user.email %>
          <% if @user.unconfirmed_email %>
            <del><%= @user.email %></del>
          <% end %>
        </dd>

        <dt class="col-sm-3">
          <%= t(".status") %>
        </dt>
        <dd class="col-sm-9">
          <% if @user.admin? %>
              <span class="badge badge-success">
                <%= t("admin.users.shared.status.admin") %>
              </span>
          <% end %>
          <% unless @user.confirmed? %>
              <span class="badge badge-warning">
                <%= t("admin.users.shared.status.pending_confirmation") %>
              </span>
          <% end %>
          <% if @user.pending_reconfirmation? %>
              <span class="badge badge-warning">
                <%= t("admin.users.shared.status.pending_reconfirmation") %>
              </span>
          <% end %>
          <% if @user.created_by_invite? && !@user.invited_to_sign_up? %>
              <span class="badge badge-warning">
                <%= t("admin.users.shared.status.inviting") %>
              </span>
          <% end %>
          <% if @user.access_locked? %>
              <span class="badge badge-danger">
                <%= t("admin.users.shared.status.locked") %>
              </span>
          <% end %>
          &nbsp;
        </dd>

        <dt class="col-sm-3">
          <%= t(".created_at") %>
        </dt>
        <dd class="col-sm-9">
          <%= time_tag @user.created_at %>
        </dd>

        <dt class="col-sm-3">
          <%= t(".current_sign_in_at") %>
        </dt>
        <dd class="col-sm-9">
          <% if @user.current_sign_in_at %>
            <%= time_tag @user.current_sign_in_at %>
          <% end %>
        </dd>
      </dl>
    </div>
  </div>
</div>
